<?php
$host = 'localhost';
$username = 'root';
$password = 'fred';

function format( $title, $var )
{
	echo "<b>$title</b><br/>";
	echo "<pre>";
	print_r ( $var );
	echo "</pre>";
}
$mysqli = new mysqli ( $host, $username, $password );
$stats = $mysqli->stat ();
format ( 'Orginal', $stats );
format ( 'All UpperCase', strtoupper ( $stats ) );
format ( 'All LowerCase', strtolower ( $stats ) );
format ( 'First UpperCase', $stats );
format ( 'Substring', substr ( $stats, 0, 22 ) );
format ( 'Splitting Strings', str_split ( $stats, 10 ) );
format ( 'Counting Strings', str_word_count ( $stats ) );
format ( 'String Explode', explode ( ':', $stats ) );

//preg_split('/ /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
format ( 'String Regexpres', preg_split ( '/ /', $stats, - 1, PREG_SPLIT_DELIM_CAPTURE ) );

$t = 'threads: 42';
$statArray = preg_split ( '/ /', $stats );
$uptimeArr = $statArray[ 0 ] . $statArray[ 1 ];
$threadArr = $statArray[ 3 ] . $statArray[ 4 ];
$questArr = $statArray[ 6 ] . $statArray[ 7 ];
$slowArr = $statArray[ 9 ] . $statArray[ 10 ];
$openArr = $statArray[ 13 ] . $statArray[ 14 ];
$flushArr = $statArray[ 16 ] . $statArray[ 18 ];
$openTableArr = $statArray[ 20 ] . $statArray[ 21 ] . $statArray[ 22 ];
$queryArr = $statArray[ 24 ] . $statArray[ 25 ] . $statArray[ 26 ] . $statArray[ 27 ] . $statArray[ 28 ];
format ( 'String Test Regexpres', preg_split ( '/ /', $stats ) );
format ( 'Status Array', array( 
	'uptime' => $uptimeArr, 'threads' => $threadArr, 'requests' => $questArr, 'slow' => $slowArr, 'open' => $openArr, 'opentables' => $openTableArr, 'flush' => $flushArr, 'query' => $queryArr 
) );
?>